<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" ></meta>
	<#include "../common.html" />
</head>
<body>
	<div  class="easyui-panel" data-options="fit:true,border:false">
		<form id="newPermissionForm" style="margin: 70px 110px;">
			<input type="hidden" name="id" value="${permission.id}">
			<table>
				<tr>
					<td>类型</td><td><input type="radio" name="type" value="0" checked/>目录<input type="radio" name="type" value="1"/>菜单<input type="radio" name="type" value="2"/>按钮</td>
				</tr>
				<tr id = "pid" style="display: none">
					<td>上级目录</td><td><input type="text" name="pid" id="pid_combobox" style="width: 173px;" class="easyui-combobox"/></td>
				</tr>
				<tr>
					<td>权限名称</td><td><input type="text" name="name" value="${permission.name}" style="width: 173px;" class="easyui-validatebox" data-options="required:true,validType:['length[1,20]']"/></td>
				</tr>
				<tr style="display: none">
					<td>图标</td><td><input type="text" name="icon" value="${permission.icon!}" style="width: 173px;" class="easyui-validatebox" data-options="validType:['length[1,20]']"/></td>
				</tr>
				<tr>
					<td>排序</td><td><input type="text" name="sort" value="${permission.sort}" style="width: 173px;" class="easyui-validatebox" data-options="required:true,validType:['length[1,20]']"/></td>
				</tr>
				<tr>
					<td>权限编码</td><td><input type="text" name="permCode" value="${permission.permCode}" style="width: 173px;" class="easyui-validatebox" data-options="required:true,validType:['length[1,20]']"/></td>
				</tr>
				<tr>
					<td>url</td><td><input type="text" name="url" value="${permission.url}" style="width: 173px;" class="easyui-validatebox" data-options="required:true,validType:['length[1,100]']"/></td>
				</tr>
				<tr>
					<td>描述</td><td><input type="text" name="description" value="${permission.description}" style="width: 173px;" class="easyui-validatebox" data-options="required:true,validType:['length[1,20]']"/></td>
				</tr>
				<tr>
					<td>状态</td><td><input type="radio" name="status" value="1" checked/>启用<input type="radio" name="status" value="0"/>禁用</td>
				</tr>

			</table>
		</form>
	<script>
		$(document).ready(function(){
			$("input[name=type][value=${permission.type}]").attr("checked","checked");
			if(${permission.type} == 1 || ${permission.type} == 2){
				$("#pid").show();
			}
			$("#pid_combobox").combobox('setValue', '${permission.pid}');
			$("input[name=status][value=${permission.status}]").attr("checked","checked");
			$("input[name=type]").change(function(){
				var type = $(this).val();
				if(type == 0){
					$("#pid").hide();
				}
				if(type==1|type==2){
					$("#pid").show();
					$("#pid_combobox").combobox({
						url:'/easyui/permission/parentMenu?type='+type,
						//data:[{"id":1,"name":'222'}],
						method:'get',
						valueField:'id',
						textField:'name',
						panelHeight:'auto'
					});
				}

			});
		});

	function submitPermission($permissionDialog,$permissionGrid,$pjq){
        var form= $("#newPermissionForm");
        var isValid = $(form).form('validate');
        
        if(isValid){
        	var data = ns.serializeObject(form);
            $.ajax({
                type : 'post',
                url : '/admin/permission/updatePermission',
                data :data,
                dataType : 'json',
                success : function(result) {
                    if(result.success){
                        $pjq.messager.alert('提示', result.msg, 'info',function(r){
							$permissionDialog.dialog('destroy');
							$permissionGrid.treegrid('reload');
         		     	});
                    }else{
                        $pjq.messager.alert('错误',result.msg,'error');
                    }
                }
            });
        }
	}
	</script>
	</div>
</body>
</html>